const sm2 = require('sm-crypto').sm2
const cipherMode = 1 // 1 - C1C3C2，0 - C1C2C3，默认为1
const publicKey = "04D4BDF1A660C728418D685A702C5E16EAA2463471BC23107CBDBBB4AD7AF526F88E89EBC7D3075D826F8323657858A351A709423B18A685CDAD141E671C32E8D4"
const privateKey = "0AC55910CF19346F35324577E7F3F0C544A7823B154B756D63160FD1167992B2"

// 加密
export function encrypt(txt) {
  let encryptData = sm2.doEncrypt(txt, publicKey, 1) // 加密结果
  return '04' + encryptData;
}

//解密
export function decrypt(cipher) {
  return sm2.doDecrypt(cipher, privateKey, 1,{output : 'string'}) // 加密结果
}
